package com.example.pagingdemo.model;

import androidx.annotation.Nullable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import com.google.gson.annotations.SerializedName;

import java.sql.Types;

/**
 * @author: tuyrt7 on 2020/9/9.
 */
@Entity(tableName = "github_user")
public class GithubUser {

    @PrimaryKey()
    @ColumnInfo(defaultValue = "id",typeAffinity = ColumnInfo.INTEGER)
    @SerializedName("id")
    public int id;

    @ColumnInfo(defaultValue = "name",typeAffinity = ColumnInfo.TEXT)
    @SerializedName("login")
    public String name;

    @ColumnInfo(defaultValue = "avatar",typeAffinity = ColumnInfo.TEXT)
    @SerializedName("avatar_url")
    public String avatar;

    @Override
    public boolean equals(@Nullable Object obj) {
        if (obj == null || !(obj instanceof GithubUser)) {
            return false;
        }
        GithubUser newObj = (GithubUser) obj;
        return id == newObj.id
                && name.equals(newObj.name)
                && avatar.equals(newObj.avatar);
    }

    @Override
    public String toString() {
        return "GithubUser{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", avatar='" + avatar + '\'' +
                '}';
    }
}
